package com.example.location;

import android.content.Context;
import android.location.LocationListener;
import android.location.LocationManager;
import android.location.LocationProvider;
import android.os.Handler;

import com.example.myfirstapp.MainActivity;

public class LocationService {
	
    // UI handler codes.
    public static final int UPDATE_ADDRESS = 1;
    public static final int UPDATE_LATLNG = 2;

    private static final int TEN_SECONDS = 10000;
    private static final int TEN_METERS = 10;
    private static final int TWO_MINUTES = 1000 * 60 * 2;
	
	public LocationManager locationManager;
	public LocationProvider provider;
	public LocationListener locationListener;
	public boolean gpsEnabled; 
	
	private static Handler handler;
	private MainActivity activity;
	
	public LocationService(MainActivity mainActivity) {
		activity = mainActivity;
		handler = new ListenerHandler(mainActivity);
		locationListener = new MyLocationListener(handler);
		
		locationManager = (LocationManager) activity.getSystemService(Context.LOCATION_SERVICE);
		locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
				TEN_SECONDS,          // 10-second interval.
		        TEN_METERS,             // 10 meters.
		        locationListener);
		
		provider = locationManager.getProvider(LocationManager.GPS_PROVIDER);
		
	    gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
	}
	

}
